package com.css;


import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
import org.springframework.core.io.UrlResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.util.StringUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;

/**
 * <p>
 * -
 * </p>
 *
 * @author css
 * @since 2020/2/29
 */
public class Const {
    private static String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";

    public static void main(String[] args) throws IOException {
//        AnnotationConfigServletWebServerApplicationContext



        Const _const = new Const();
        ClassLoader classLoader = _const.getClass().getClassLoader();
        Enumeration<URL> urls = (classLoader != null ?
            classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :
            ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
        System.out.println(urls);
        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            UrlResource resource = new UrlResource(url);
            Properties properties = PropertiesLoaderUtils.loadProperties(resource);
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                String factoryTypeName = ((String) entry.getKey()).trim();
                for (String factoryImplementationName : StringUtils.commaDelimitedListToStringArray((String) entry.getValue())) {
                    System.out.println(factoryTypeName);
                }
            }
        }
    }

    public final static Integer userId = 1;
    public final static String CURRENT_USER = "CURRENT_USER";
    public final static Integer maxStudyNum = 2;
    public static final String TOKEN_KEY = "TOKEN";
    public static final Integer RECRUIT_ALL = 1;
    public static final Integer RECRUITED = 99;
    public static final Integer FULL_HANDLE_DISCARD = 0;
    public static final Integer FULL_HANDLE_MAIL = 1;
    public static final Integer EQUIP_HAT = 3;
    public static final Integer EQUIP_CLOTHES = 4;
    public static final Integer EQUIP_ARMS = 5;
    public static final Integer EQUIP_SHOES = 6;
    public static final Integer GENERAL_TYPE_WHITE = 0;
    public static final Integer GENERAL_TYPE_GREEN = 1;
    public static final Integer GENERAL_TYPE_BLUE = 2;
    public static final Integer GENERAL_TYPE_PURPLE = 3;
    public static final Integer GENERAL_TYPE_ORANGE = 4;
    public static final Integer GENERAL_TYPE_RED = 5;

    //css//武将升级经验
    public static final Integer CONST_GENERAL_LEVEL_EXP = 1;
    public static final Integer CONST_GENERAL_LEVEL_STRENG = 2;
    public static final Integer CONST_GENERAL_LEVEL_FORGE = 3;
    //css//玩家升级经验
    public static final Integer CONST_USER_LEVEL_EXP = 4;
    public static final Integer CONST_ARENA_INTEGRAL = 5;
    public static final Integer DEL = 1;
    public static final Integer GOODS_DIAMOND_TYPE = 41;
    public static final Integer PROBABILITY_100 = 100;
    public static final Integer PASS_NO = 0;
    public static final Integer PASS_ING = 1;
    public static final Integer PASS = 2;
//    public static final Integer GOODS_DIAMOND = 21;
//    public static final Integer GOODS_DIAMOND = 22;
//    public static final Integer GOODS_DIAMOND = 23;
//    public static final Integer GOODS_DIAMOND = 24;

    //    public static final List<IntegralVo> INTEGRAL_LIST = new ArrayList<>();
//    public static final Collection<BasGoodsVo> REWARD_GOODS_LIST = new ArrayList<>();
    public static final Integer REFRESH_SILVER_TICKET = 50;
    public static final Integer REFRESH_SILVER_TICKET_PROSPERITY = 5;
    public static final Integer REFRESH_YUANBAO = 10;
    public static final Integer REFRESH_YUANBAO_PROSPERITY = 10;
    public static final Integer PUB_MAX_PROSPERITY = 10000;

    public static final Integer GENERAL_STATUS_OCCUPY_RESOURCE = 4;

//    public static final Integer GET_INTEGRAL(Integer rank) {
//        for (IntegralVo integralVo : INTEGRAL_LIST) {
//            if (rank >= integralVo.getMinRank() && rank <= integralVo.getMaxRank()) {
//                return integralVo.getIntegral();
//            }
//        }
//        return 10;
//    }

    static {
//        INTEGRAL_LIST.add(new IntegralVo(1, 1, 200));
//        INTEGRAL_LIST.add(new IntegralVo(2, 2, 180));
//        INTEGRAL_LIST.add(new IntegralVo(3, 3, 165));
//        INTEGRAL_LIST.add(new IntegralVo(4, 4, 155));
//        INTEGRAL_LIST.add(new IntegralVo(5, 5, 145));
//        INTEGRAL_LIST.add(new IntegralVo(6, 6, 135));
//        INTEGRAL_LIST.add(new IntegralVo(7, 7, 125));
//        INTEGRAL_LIST.add(new IntegralVo(8, 8, 115));
//        INTEGRAL_LIST.add(new IntegralVo(9, 9, 105));
//        INTEGRAL_LIST.add(new IntegralVo(10, 10, 100));
//        INTEGRAL_LIST.add(new IntegralVo(11, 50, 80));
//        INTEGRAL_LIST.add(new IntegralVo(51, 100, 70));
//        INTEGRAL_LIST.add(new IntegralVo(101, 200, 60));
//        INTEGRAL_LIST.add(new IntegralVo(201, 500, 50));
//        INTEGRAL_LIST.add(new IntegralVo(501, 1000, 40));
//        INTEGRAL_LIST.add(new IntegralVo(1001, 2000, 30));
//        INTEGRAL_LIST.add(new IntegralVo(2001, 4000, 20));
//        INTEGRAL_LIST.add(new IntegralVo(4001, Integer.MAX_VALUE, 10));
    }
}
